<template>
  <div>
    <div class="textTile flex-h">
      <span class="sp1 flex1">成长环境测试</span>
      <span class="sp2"
        ><b>{{ tabNum + 1 }}</b
        ><i>/10</i></span
      >
    </div>
    <div v-for="(item, index) in dyznData.history" :key="index">
      <div class="textQuestions" v-show="index === tabNum">
        <span>{{ item.issue }}</span>
      </div>
      <div class="commonBox has-bottombar grown" v-show="index === tabNum">
        <span class="sp1" @click="clcyes(index, 1, item.score)">{{ item.ans1 }}</span>
        <span class="sp1" @click="clcyes(index, 2, item.score)">{{ item.ans2 }}</span>
        <span class="sp1" @click="clcyes(index, 3, item.score)">{{ item.ans3 }}</span>
        <span class="sp1" @click="clcyes(index, 4, item.score)">{{ item.ans4 }}</span>
        <span class="sp1" @click="clcyes(index, 5, item.score)">{{ item.ans5 }}</span>
        <span class="sp1" @click="clcyes(index, 6, item.score)">{{ item.ans6 }}</span>
        <!-- <span class="flex1 sp1" @click="clcno(index)">不能</span> -->
      </div>
    </div>
  </div>
</template>

<script>
import ls from 'store2'
import dyznData from '~/static/json/grown.json'
export default {
  props: {},
  components: {},
  data() {
    return {
      tabNum: 0,
      dyznData: dyznData,
      grownSmScore: [0, 0, 0, 0, 0, 0],
      grownBigScore: [0, 0, 0]
    }
  },
  computed: {},
  mounted: function() {},
  methods: {
    clcyes(indexs, stats, score) {
      switch (stats) {
        case 1:
          this.grownSmScore[0] += score
          break
        case 2:
          this.grownSmScore[1] += score
          break
        case 3:
          this.grownSmScore[2] += score
          break
        case 4:
          this.grownSmScore[3] += score
          break
        case 5:
          this.grownSmScore[4] += score
          break
        default:
          this.grownSmScore[5] += score
      }

      if (this.tabNum === 9) {
        this.$loading('open')
        let obj = {
          status: 5,
          worthScore: this.grownSmScore
        }
        ls.set('resultPar', obj)
        this.commonJs.gosto('IndResult')
      } else {
        this.tabNum = indexs + 1
      }
    }
  }
}
</script>

<style scoped lang="less">
.textTile {
  padding-bottom: 0.4rem;
  height: auto;
  width: 100%;
  border-bottom: 0.01rem solid rgba(238, 238, 238, 1);

  .sp1 {
    font-size: 0.4rem;
    font-weight: bold;
    color: rgba(34, 34, 34, 1);
    line-height: 0.44rem;
  }

  .sp2 {
    b {
      font-size: 0.4rem;
      font-weight: bold;
      color: @mainColor;
    }

    i {
      font-size: 0.22rem;
      font-weight: bold;
      color: rgba(187, 187, 187, 1);
      // line-height:30px;
    }
  }
}
.textQuestions {
  width: 100%;
  height: auto;
  padding-top: 0.3rem;

  span {
    font-size: 0.32rem;
    font-weight: bold;
    color: rgba(34, 34, 34, 1);
    line-height: 0.45rem;
  }
}

.titlesDrag {
  width: 100%;
  height: 0.8rem;
  margin-top: 0.5rem;

  .sp1,
  .sp2 {
    font-size: 0.26rem;
    font-weight: bold;
    box-sizing: border-box;
    height: 0.8rem;
  }

  .sp1 {
    width: 1.5rem;
    padding-top: 0.4rem;
    color: @mainColor;
  }

  .sp2 {
    padding-top: 0.2rem;

    color: rgba(187, 187, 187, 1);
  }
}

.titlesDrag1 {
  height: 0.4rem;
  margin-top: 0;
  font-size: 0.3rem;

  .sp1,
  .sp2 {
    height: 0.4rem;
    padding-top: 0;
    color: rgba(187, 187, 187, 1);
  }
}

.commonBox {
  position: absolute;
  width: 100%;
  height: auto;
  left: 0;
  bottom: 0.4rem;
  padding: 0 0.3rem;
  box-sizing: border-box;
}

.grown {
  .sp1 {
    width: 6.2rem;
    height: auto;
    border-radius: 0.1rem;
    padding: 0.2rem;
    border: 0.02rem solid rgba(238, 238, 238, 1);
    font-size: 0.3rem;
    display: block;
    font-weight: bold;
    color: rgba(34, 34, 34, 1);
    line-height: 0.4rem;
    text-align: left;
    box-sizing: border-box;
    margin-top: 0.15rem;
  }

  .sp3 {
    width: 6.1rem;
    height: 0.9rem;
    border-radius: 0.1rem;
    border: 0.02rem solid @mainColor;
    margin: 0 auto;
    display: block;
    line-height: 0.9rem;
    text-align: center;
    font-size: 0.3rem;
    font-weight: bold;
    color: @mainColor;
  }

  span:nth-of-type(1) {
    margin-right: 0.2rem;
  }
}
</style>
